import { useRef } from "react";

import { TaskItem } from "../components/Home/home";

import { AnalysisList } from "~/components/Home/analysisList";
import NewAnalysis from "~/components/Home/newAnalysis";

const Index = () => {
  const newAnalysis = useRef();
  // 新建任务
  const onNewAnalysis = () => {
    newAnalysis.current && (newAnalysis.current as any).onOpen("add");
  };
  // 编辑任务
  const onEdit = (value: TaskItem) => {
    newAnalysis.current && (newAnalysis.current as any).onOpen("edit", value);
  };

  return (
    <div className="w-100%  pl-16px pr-16px">
      <div className="bg-#FFF overflow-auto">
        <AnalysisList add={onNewAnalysis} edit={onEdit} />
      </div>
      <div>
        <NewAnalysis ref={newAnalysis} />
      </div>
    </div>
  );
};

export default Index;
